<template>
  <div class="app-container">
    <el-dialog :title="'分配美工'+'（'+form.orderNo+'）'" :visible.sync="dialogVisible" width="30%" append-to-body>
      <el-form ref="form" :model="form" v-loading="loading" label-position="top">
        <el-form-item label="人员名称" prop="drawUserId" required>
          <el-select v-model="form.drawUserId" filterable style="width: 100%">
            <el-option
              v-for="item in selectList"
              :key="item.userId"
              :label="item.nickName"
              :value="item.userId">
            </el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible=false">取 消</el-button>
        <el-button type="primary" @click="dialogOk" v-loading="loading">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {updateSaleOrderExpress} from "../../../../api/saleMng";
import {listAssignUser, okAssignUser} from "../../../../api/imsMng";

export default {
  dicts: ['ims_bank_name'],
  data() {
    return {
      loading: false,
      dialogVisible: false,
      form: {
        drawUserId: ''
      },
      selectList: []
    }
  },
  methods: {
    show(form) {
      this.dialogVisible = true
      this.form = {}
      this.resetForm('form')
      this.form.id = form.id
      this.form.orderNo = form.orderNo
      this.$set(this.form, 'drawUserId', form.drawUserId)
      this.load()
    },
    load() {
      this.loading = true
      listAssignUser({pageSize: -1}).then(res => {
        this.selectList = res.data
      }).finally(e => {
        this.loading = false
      })
    },
    dialogOk() {
      this.$refs.form.validate(e => {
        if (e) {
          this.loading = true
          okAssignUser(this.form).then(res => {
            this.$emit('ok')
            this.dialogVisible = false
            this.$message.success('分配成功')
          }).finally(e => {
            this.loading = false
          })
        }
      })
    },
  }
}
</script>
